#pragma once

#include <Network/TcpIoLoop.h>
#include <Network/TcpConnection.h>

struct TcpPacket;
class TcpConnectionEventHandler;

class TcpServer
{
public:
	TcpServer(TcpIoLoop& ioLoop, TcpConnectionEventHandler* eventHandler);
	~TcpServer(void);

	bool Start(std::string& ip, std::string& port);
	void Stop();

private:
	void OnAcceptCompleted(TcpConnection* connection, const boost::system::error_code& e);
	
private:
	TcpIoLoop& ioLoop_;
	std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor_;
	TcpConnectionEventHandler* eventHandler_;
};
